home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / net / netRoute.h < prev    next >
C/C++ Source or Header  |  1991-04-01  |  4KB  |  130 lines

  1. /*
  2.  * netRoute.h --
  3.  *
  4.  *    Definitions for the routing part of the network module.
  5.  *    Other modules specify a Sprite host ID when sending messages
  6.  *    via the net module.  The net module maintains routing
  7.  *    information that maps from these Sprite host IDs to physical addresses.
  8.  *
  9.  * Copyright 1986, 1988 Regents of the University of California
  10.  * Permission to use, copy, modify, and distribute this
  11.  * software and its documentation for any purpose and without
  12.  * fee is hereby granted, provided that the above copyright
  13.  * notice appear in all copies.  The University of California
  14.  * makes no representations about the suitability of this
  15.  * software for any purpose.  It is provided "as is" without
  16.  * express or implied warranty.
  17.  *
  18.  *
  19.  * $Header: /sprite/src/kernel/net/RCS/netRoute.h,v 9.6 91/03/15 15:48:19 jhh Exp $ SPRITE (Berkeley)
  20.  */
  21.  
  22. #ifndef _NETROUTE
  23. #define _NETROUTE
  24.  
  25. #ifdef KERNEL
  26. #include <sprite.h>
  27. #include <list.h>
  28. #include <netInet.h>
  29. #include <user/net.h>
  30. #include <netTypes.h>
  31. #else
  32. #include <sprite.h>
  33. #include <list.h>
  34. #include <netInet.h>
  35. #include <net.h>
  36. #include <kernel/netTypes.h>
  37. #endif
  38.  
  39. /*
  40.  * Maximum size for all headers of a packet.  We allow 8 extra bytes for
  41.  * alignment purposes.
  42.  */
  43. #define NET_MAX_HEADER_SIZE (sizeof(Net_UltraHeader) + sizeof(Net_IPHeader) + 8)
  44.  
  45. /*
  46.  * A Route: A mapping between a physical address and a Sprite Host ID.
  47.  * The supported address type is just ethernet. Net_Routes are manipulated
  48.  * by Net_InstallRoute and Net_AddrToID.  The main point of a Net_Route
  49.  * is that it holds a pre-packaged transport header that is pre-pended
  50.  * onto messages being sent to the Sprite Host.
  51.  *
  52.  */
  53. typedef struct Net_Route {
  54.     List_Links        links;        /* Used to add routes to a list. */
  55.     int            routeID;    /* ID unique to this route. */
  56.     int            protocol;    /* see values defined below */
  57.     Net_Address        netAddress[NET_MAX_PROTOCOLS];/* host addresses */
  58.     int            spriteID;    /* Universal Sprite ID */
  59.     int            flags;        /* See below. */
  60.     int            refCount;    /* Reference count. */
  61.     char        desc[64];    /* Route description.  Useful
  62.                      * for debugging. */
  63.     Address        headerPtr[NET_MAX_PROTOCOLS]; /* Start of transport 
  64.                                * headers*/
  65.     Net_Interface    *interPtr;    /* Which network interface to use. */
  66.     int            maxBytes;    /* Maximum transfer unit of route. */
  67.     int            minBytes;    /* Minimum transfer unit of route. */
  68.     ClientData        userData;    /* Space available for user program
  69.                      * that manipulates routes. */
  70.     char        buffer[NET_MAX_HEADER_SIZE];  /* Network packet 
  71.                                * header(s). */
  72. } Net_Route;
  73.  
  74. /*
  75.  * Flag values for Net_Route.
  76.  */
  77.  
  78. #define NET_RFLAGS_VALID    0x1    /* The route is valid. */
  79. #define NET_RFLAGS_DELETING    0x2    /* Route is being deleted. */
  80.  
  81. /*
  82.  * The following two constants define the minimum and maximum
  83.  * number of free routes on the free list.  Once the number drops
  84.  * below the minimum we add routes to the list until there are the
  85.  * maximum.  Make sure that the difference between the minimum and
  86.  * maximum is enough to allocate all of the broadcast routes during
  87.  * initialization since the callback stuff is initialized later.
  88.  */
  89.  
  90. #define NET_MIN_FREE_ROUTES 8
  91. #define NET_MAX_FREE_ROUTES (NET_MIN_FREE_ROUTES + NET_MAX_INTERFACES + 2)
  92.  
  93. /*
  94.  *  Variables corresponding to the above two constants.
  95.  */
  96.  
  97. extern    int    netMinFreeRoutes;
  98. extern    int    netMaxFreeRoutes;
  99.  
  100. /*
  101.  * This structure contains host information that is common to all routes
  102.  * to the host. The name is used for error reporting.
  103.  * The machine type is queried by the file system when it has to expand
  104.  * $MACHINE during pathname lookup.
  105.  */
  106.  
  107. typedef struct NetHostInfo {
  108.     char    name[20];        /* The host name. */
  109.     char    machType[12];        /* Host machine type. */
  110. } NetHostInfo;
  111.  
  112. /*
  113.  * The routing table
  114.  */
  115. extern List_Links netRouteArray[];
  116. extern NetHostInfo netHostInfo[];
  117.  
  118.  
  119. /*
  120.  * Forward declarations.
  121.  */
  122.  
  123. extern void NetArpInput _ARGS_((Net_Interface *interPtr, Address packetPtr, 
  124.                 int packetLength));
  125. extern void NetAddToFreeRouteList _ARGS_((ClientData data, 
  126.                 Proc_CallInfo *infoPtr));
  127. extern void NetFreeRoute _ARGS_((Net_Route *routePtr));
  128.  
  129. #endif /* _NETROUTE */
  130.